﻿namespace Chain.BLL
{
    using Chain.IDAL;
    using Chain.Model;
    using System;
    using System.Collections.Generic;
    using System.Data;

    public class StaffMoney
    {
        private readonly Chain.IDAL.StaffMoney dal = new Chain.IDAL.StaffMoney();

        public int Add(Chain.Model.StaffMoney model)
        {
            return this.dal.Add(model);
        }

        public List<Chain.Model.StaffMoney> DataTableToList(DataTable dt)
        {
            List<Chain.Model.StaffMoney> list = new List<Chain.Model.StaffMoney>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Chain.Model.StaffMoney item = new Chain.Model.StaffMoney();
                    if ((dt.Rows[i]["StaffMoneyID"] != null) && (dt.Rows[i]["StaffMoneyID"].ToString() != ""))
                    {
                        item.StaffMoneyID = int.Parse(dt.Rows[i]["StaffMoneyID"].ToString());
                    }
                    if ((dt.Rows[i]["StaffID"] != null) && (dt.Rows[i]["StaffID"].ToString() != ""))
                    {
                        item.StaffID = int.Parse(dt.Rows[i]["StaffID"].ToString());
                    }
                    if ((dt.Rows[i]["StaffTotalMoney"] != null) && (dt.Rows[i]["StaffTotalMoney"].ToString() != ""))
                    {
                        item.StaffTotalMoney = decimal.Parse(dt.Rows[i]["StaffTotalMoney"].ToString());
                    }
                    if ((dt.Rows[i]["StaffOrderCode"] != null) && (dt.Rows[i]["StaffOrderCode"].ToString() != ""))
                    {
                        item.StaffOrderCode = dt.Rows[i]["StaffOrderCode"].ToString();
                    }
                    if ((dt.Rows[i]["StaffMemID"] != null) && (dt.Rows[i]["StaffMemID"].ToString() != ""))
                    {
                        item.StaffMemID = int.Parse(dt.Rows[i]["StaffMemID"].ToString());
                    }
                    if ((dt.Rows[i]["StaffGoodsID"] != null) && (dt.Rows[i]["StaffGoodsID"].ToString() != ""))
                    {
                        item.StaffGoodsID = int.Parse(dt.Rows[i]["StaffGoodsID"].ToString());
                    }
                    if ((dt.Rows[i]["StaffShopID"] != null) && (dt.Rows[i]["StaffShopID"].ToString() != ""))
                    {
                        item.StaffShopID = int.Parse(dt.Rows[i]["StaffShopID"].ToString());
                    }
                    if ((dt.Rows[i]["StaffCreateTime"] != null) && (dt.Rows[i]["StaffCreateTime"].ToString() != ""))
                    {
                        item.StaffCreateTime = DateTime.Parse(dt.Rows[i]["StaffCreateTime"].ToString());
                    }
                    if ((dt.Rows[i]["StaffOrderDetailID"] != null) && (dt.Rows[i]["StaffOrderDetailID"].ToString() != ""))
                    {
                        item.StaffOrderDetailID = int.Parse(dt.Rows[i]["StaffOrderDetailID"].ToString());
                    }
                    if ((dt.Rows[i]["StaffType"] != null) && (dt.Rows[i]["StaffType"].ToString() != ""))
                    {
                        item.StaffType = int.Parse(dt.Rows[i]["StaffType"].ToString());
                    }
                    list.Add(item);
                }
            }
            return list;
        }

        public bool Delete(int StaffMoneyID)
        {
            return this.dal.Delete(StaffMoneyID);
        }

        public bool DeleteList(string StaffMoneyIDlist)
        {
            return this.dal.DeleteList(StaffMoneyIDlist);
        }

        public int DeleteStaff(string strStaffOrderCode)
        {
            return this.dal.DeleteStaff(strStaffOrderCode);
        }

        public bool Exists(int StaffMoneyID)
        {
            return this.dal.Exists(StaffMoneyID);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public DataSet GetListSP(string strWhere)
        {
            return this.dal.GetListSP(strWhere);
        }

        public int GetMaxId()
        {
            return this.dal.GetMaxId();
        }

        public Chain.Model.StaffMoney GetModel(int StaffMoneyID)
        {
            return this.dal.GetModel(StaffMoneyID);
        }

        public List<Chain.Model.StaffMoney> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public DataSet GetStaffMoney(string strWhere)
        {
            return this.dal.GetStaffMoney(strWhere);
        }

        public DataSet GetStaffMoneyByTime(DateTime starttime, DateTime endtime, string strwhere)
        {
            return this.dal.GetStaffMoneyByTime(starttime, endtime, strwhere);
        }

        public decimal GetStaffTotalMoney(string strSql)
        {
            return this.dal.GetStaffTotalMoney(strSql);
        }

        public decimal GetTotalStaffMoney(string strWhere)
        {
            return this.dal.GetTotalStaffMoney(strWhere);
        }

        public bool Update(Chain.Model.StaffMoney model)
        {
            return this.dal.Update(model);
        }

        public int UpdateStaffMoney(string strOrderCode, int intGoodsID, decimal money)
        {
            return this.dal.UpdateStaffMoney(strOrderCode, intGoodsID, money);
        }
    }
}

